//
//  NSObject+MC_JSON.m
//  RetainCount
//
//  Created by liuxiang on 2017/12/4.
//  Copyright © 2017年 liuxiang. All rights reserved.
//

#import "NSObject+MC_JSON.h"

@implementation NSObject (MC_JSON)

- (NSString *) mc_toJSONString {
    if([NSJSONSerialization isValidJSONObject:self]) {
       NSData *data = [NSJSONSerialization dataWithJSONObject:self options:NSJSONWritingPrettyPrinted error:nil];
        if (data) {
            NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
            return jsonString;
        }
        return nil;
    }else {
        return nil;
    }
    
}

@end
